<section>
	<div class="page-header">
		<h2><?php echo $title; ?></h2>
	</div>
	
	<?php echo form_open('', array('autocomplete' => 'off')); ?>
		<div class="clearfix">
			<label>Title <span class="req">*</span></label>
			<div class="input">
				<input type="text" name="page_title" value="<?php echo $page['title']; ?>" />
			</div>
		</div>
		<div class="clearfix">
			<label>Meta Description</label>
			<div class="input">
				<textarea name="meta_description" class="xxlarge"><?php echo $page['meta_description']; ?></textarea>
			</div>
		</div>
		<div class="clearfix">
			<label>Type <span class="req">*</span></label>
			<div class="input">
				<?php echo show_array_dropdown($categories, 'content_category_id', 'name', $page['ancestor'] == 0 ? $page['content_category_id'] : $page['ancestor'], 'cat'); ?>
			</div>
		</div>
		<div class="clearfix">
			<label>Category <span class="req">*</span></label>
			<div class="input">
				<select name="category" id="category"></select>
			</div>
		</div>
		<div class="clearfix">
			<label>Website <span class="req">*</span></label>
			<div class="input">
				<?php echo show_array_dropdown($websites, 'site_code', 'site_name', $page['site_code'], 'websites'); ?>
			</div>
		</div>
		<div class="clearfix">
			<label>Content <span class="req">*</span></label>
			<div class="input">
				<textarea id="mainbody" name="content" class="xxlarge" style="margin-bottom: 10px;"><?php echo $page['html_code']; ?></textarea>
				<br/>
				<span class="btn small toggle">Toggle Editor</span>
			</div>
		</div>
		<div class="clearfix">
			<label>Actions</label>
			<div class="input">
				<ul class="inputs-list">
					<li>
						<label>
							<input type="checkbox" name="featured" value="y" <?php if ($page['featured'] == 'y') echo 'checked="checked"'; ?> />
							<span>Featured</span>
						</label>
					</li>
					<li>
						<label>
							<input type="checkbox" name="published" value="y" <?php if ($page['published'] == 'y') echo 'checked="checked"'; ?> />
							<span>Published</span>
						</label>
					</li>
				</ul>
			</div>
		</div>
		<div class="actions">
			<button type="submit" class="btn primary">Save</button>
			<?php echo anchor('contents/all', 'Cancel', array('class' => 'btn')); ?>
			<?php if ($page['updated']) : ?><span class="small">Last Updated: <?php echo display_time($page['updated']); ?></span><?php endif; ?>
		</div>
	</form>
</section>

<script>
	$(function() {
		showChildren('<?php echo site_url('contents/ajax_list_categories'); ?>/' + $('#cat').val(), '<?php echo $page['content_category_id']; ?>');
	});
	
	$('#cat').change(function() {
		
		var typ = $(this);
		var val = $(this).val();
		
		showChildren('<?php echo site_url('contents/ajax_list_categories'); ?>/' + val, '');
		
	});
	
</script>

<?php $this->view('tiny_mce'); ?>